# coding=utf-8

import web

class Test(object):
    @staticmethod
    def update_email(id, email):
        return web.ctx.db.update('test_result'
                , email = email
                , where = 'id = $id'
                , vars = locals())

    @staticmethod
    def add(row):
        return web.ctx.db.insert('test_result'
                , uid = row.uid
                , selections = row.selections
                , plan_dest = row.plan_dest
                , email = row.email
                , result = row.result)

    @staticmethod
    def get(id):
        set = web.ctx.db.select('test_result'
                , where = 'id = $id'
                , vars = locals())
        if set:
            return set[0]
        return False
